<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="css/common.css" rel="stylesheet" type="text/css" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="../resources/favicon.ico" th:href="@{/static/favicon.ico}"/>
    <script src="js/WebCalendar.js" type="text/javascript"></script>
</head>

<body>
<div class="wrap">
    <!-- main begin-->
    <div class="sale">
        <h1 class="lf">在线拍卖系统</h1>
        <div class="logout right"><a href="/login.html" title="注销">注销</a></div>
<!--        <input type="button" onclick="location='/login.html'"  value="注销" class="spbg buttombg f14  sale-buttom buttomb"/>-->
    </div>
    <div class="forms">

        <form id="form_query" th:action="@{/list}" method="post">
            <input type="hidden" id="pageNumber" name="pageNum" value="1"/>
            <label for="name">名称</label>
            <input name="auctionname" type="text" class="nwinput" id="name" th:value="${condition.auctionname}"/>
            <label for="names">描述</label>
            <input name="auctiondesc" type="text" id="names" class="nwinput" th:value="${condition.auctiondesc}"/>

            <label for="time">开始时间</label>
            <input name="auctionstarttime"
                   th:value="${#dates.format(condition.auctionstarttime,'yyyy-MM-dd hh:mm:ss')}"
                   type="text" id="time" class="nwinput" readonly="readonly" onclick="selectDate(this,'yyyy-MM-dd hh:mm:ss')"/>

            <label for="end-time">结束时间</label>
            <input name="auctionendtime"
                   th:value="${#dates.format(condition.auctionendtime,'yyyy-MM-dd hh:mm:ss')}"
                   type="text" id="end-time" class="nwinput" readonly="readonly" onclick="selectDate(this,'yyyy-MM-dd hh:mm:ss')"/>

            <label for="price">起拍价</label>
            <input name="auctionstartprice" type="text" id="price" class="nwinput" th:value="${condition.auctionstartprice}"/>
            <input type="submit"  value="查询" class="spbg buttombg f14  sale-buttom"/>
        </form>


        <div th:if="${session.user.userisadmin==1}">
            <input type="button" onclick="location='/addAuction'" value="发布" class="spbg buttombg f14  sale-buttom buttomb"/>
        </div>
        <div th:if="${session.user.userisadmin==0}">
            <input type="button" onclick="location='/toAuctionResult'"  value="竞拍结果" class="spbg buttombg f14  sale-buttom buttomb"/>
        </div>



    </div>
    <div class="items">
        <ul class="rows even strong">
            <li>名称</li>
            <li class="list-wd">描述</li>
            <li>开始时间</li>
            <li>结束时间</li>
            <li>起拍价</li>
            <li class="borderno">操作</li>
        </ul>
        <ul  th:each="auction,state:${auctionList}" th:class="${state.odd?'rows':'rows even'}">
            <li><a th:href="@{getAuctionById(auctionId = ${auction.auctionid})}" title="" th:text="${auction.auctionname}"></a></li>
            <li class="list-wd" th:text="${auction.auctiondesc}"></li>
            <li th:text="${#dates.format(auction.auctionstarttime,'yyyy-MM-dd hh:MM:ss')}"></li>
            <li th:text="${#dates.format(auction.auctionendtime,'yyyy-MM-dd hh:MM:ss')}"></li>
            <li th:text="${auction.auctionstartprice}"></li>
            <li class="borderno red">

          <span th:if="${session.user.userisadmin==1}">
              <a href="#" title="" onclick="dele();">修改</a>
<!--             <a href="#" title="" onclick="abc();">删除</a>-->
              <a th:href="@{/deleteByPrimaryKey(auctionId=${auction.auctionid})}">删除</a>
          </span>

                <span th:if="${session.user.userisadmin==0}">
              <a th:href="@{getAuctionById(auctionId = ${auction.auctionid})}">竞拍</a>
          </span>

            </li>
        </ul>

        <div class="page">
            当前第<span th:text="${page.pageNum}" style="color: red;font-size: 14px"></span>页,
            总共<span th:text="${page.pages}" style="color: deepskyblue;font-size: 14px"></span>页,
            总记录数 <span th:text="${page.total}" style="color: purple;font-size: 14px"></span>条,
            <a href="#" title="" th:onclick="'getPage(1)'">首页</a>
            <a href="#" title="" th:onclick="'getPage('+${page.prePage}+')'">上一页</a>
            <a href="#" title="" th:onclick="'getPage('+${page.nextPage}+')'">下一页</a>
            <a href="#" title="" th:onclick="'getPage('+${page.pages}+')'">尾页</a>
        </div>
<!--        <div class="page">-->
<!--            <a href="#" title="">首页</a>-->
<!--            <a href="#" title="">上一页</a>-->
<!--            <span class="red">前5页</span>-->
<!--            <a href="#" title="">1</a>-->
<!--            <a href="#" title="">2</a>-->
<!--            <a href="#" title="">3</a>-->
<!--            <a href="#" title="">4</a>-->
<!--            <a href="#" title="">5</a>-->
<!--            <a href="#" title="">下一页</a>-->
<!--            <a href="#" title="">尾页</a>-->
<!--        </div>-->
<!--    </div>-->
    <script>
        // 处理 分页的逻辑
        function getPage(pageNo) {

            // 将用户设置的页码 给 隐藏域 然后传递到后台
            document.getElementById("pageNumber").value =pageNo;

            // 通过js 提交表单  传递参数
            document.getElementById("form_query").submit();
        }
        function abc(){
            if(confirm("你真的确认要删除吗？请确认")){

                return true;
            }
            else{
                return false;
            }
        };
        function dele(){
            if(confirm("你真的确认要修改吗？请确认")){
                return true;
            }
            else{
                return false;
            }
        }
    </script>
    <!-- main end-->
</div>
</body>
</html>